"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1 = require('@angular/core');
var router_1 = require('@angular/router');
var auth_service_1 = require('../scheme/auth.service');
var LoginComponent = (function () {
    function LoginComponent(authService, router) {
        this.authService = authService;
        this.router = router;
    }
    ;
    LoginComponent.prototype.login = function () {
        var _this = this;
        if (this.validBirth === this.authService.validUser) {
            this.authService.login().subscribe(function () {
                if (_this.authService.isLoggedIn) {
                    // Get the redirect URL from our auth service
                    // If no redirect has been set, use the default
                    var redirect = _this.authService.redirectUrl || '/admin/bearing/list';
                    // Redirect the user
                    _this.router.navigate([redirect]);
                }
            });
        }
        else {
            alert('您的验证码不正确');
        }
    };
    ;
    LoginComponent.prototype.logout = function () {
        this.authService.logout();
    };
    ;
    LoginComponent = __decorate([
        core_1.Component({
            moduleId: module.id,
            selector: 'my-login-wraper',
            templateUrl: 'login.component.html',
            styleUrls: ['login.component.css'],
            animations: [
                core_1.trigger('sliderIn', [
                    core_1.state('in', core_1.style({
                        opacity: 1,
                        transform: 'translateX(0)'
                    })),
                    core_1.transition('void => *', [
                        core_1.animate('0.35s ease-in-out', core_1.keyframes([
                            core_1.style({ opacity: 0, transform: 'translateX(-50px)', offset: 0 }),
                            core_1.style({ opacity: .8, transform: 'translateX(20px)', offset: 0.8 }),
                            core_1.style({ opacity: 1, transform: 'translateX(0)', offset: 1.0 })
                        ]))
                    ])
                ])
            ]
        }), 
        __metadata('design:paramtypes', [auth_service_1.AuthService, router_1.Router])
    ], LoginComponent);
    return LoginComponent;
}());
exports.LoginComponent = LoginComponent;
